package com.xinlong.shop.core.temp.service.impl;

import com.xinlong.shop.core.temp.entity.BuyStatistics;
import com.xinlong.shop.core.temp.mapper.BuyStatisticsMapper;
import com.xinlong.shop.core.temp.service.IBuyStatisticsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;

/**
 * <p>
 * 访问统计-临时给老系统用的 服务实现类
 * </p>
 *
 * @author Sylow
 * @since 2022-12-23
 */
@Service
public class BuyStatisticsServiceImpl extends ServiceImpl<BuyStatisticsMapper, BuyStatistics> implements IBuyStatisticsService {

    private final BuyStatisticsMapper buyStatisticsMapper;

    public BuyStatisticsServiceImpl(BuyStatisticsMapper buyStatisticsMapper) {
        this.buyStatisticsMapper = buyStatisticsMapper;
    }

    @Override
    public void update(BuyStatistics buyStatistics, Integer id) {
        UpdateWrapper<BuyStatistics> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("id", id);
        this.update(buyStatistics, updateWrapper);
    }
    @Override
    public void delete(Integer id) {
        UpdateWrapper<BuyStatistics> deleteWrapper = new UpdateWrapper<>();
        deleteWrapper.eq("id", id);
        this.remove(deleteWrapper);
    }

    @Override
    public Integer visitNum(String ruleId, Integer pageId) {
        return this.buyStatisticsMapper.visitNum(ruleId, pageId);
    }

}
